<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>隐藏内部实现</title>
	</head>
	<body>
		<script>
			//全局污染：
			/*function foo(a) {
				var b = a * 2;
				
				bar(b);
			}
			
			function bar(b) {
				var c = b + 2;
				console.log(c);
			}
			
			foo(2);
			
			console.log(window);*/
			
			//隐藏内部实现
			function foo(a) {
				var b = a * 2;
				
				function bar() {
					var c = b + 2;
					console.log(c);
				}
				bar();
			}
			
			
			
			foo(2);
		</script>
	</body>
</html>
